import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: '首页',
    component: HomeView,
    meta: {
      title: "陈愉-陈万超"
    }
  },
  {
    path: '/about-us',
    name: '关于我们',
    component: () => import('../views/AboutUsView'),
    meta: {
      title: "陈广仪"
    }
  },
  {
    path: '/news-center',
    name: '新闻中心',
    component: () => import('../views/NewsCenterView'),
    meta: {
      title: "张虎"
    }
  },
  {
    path: '/shop-list',
    name: '门店列表',
    component: () => import('../views/ShopListView'),
    meta: {
      title: "张虎"
    }
  },
  {
    path: '/petclass',
    name: 'petclass',
    component: () => import('../views/PetClassView.vue'),
    meta: {
      title: "李雄"
    }
  },
  {
    path: '/medical-team',
    name: 'medical-team',
    component: () => import('../views/MedicalTeamView'),
    meta: {
      title: "刘松"
    }
  },
  {
    path: '/armarium',
    name: 'armarium',
    component: () => import('../views/ArmariumView.vue'),
    meta: {
      title: "吴莉云"
    }
  },
  {
    path: '/contact-us',
    name: 'contact-us',
    component: () => import('../views/ContactUsView'),
    meta: {
      title: "吴莉云"
    }
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router
